<template>
    <div tabindex="0" class="filter-item el-upload el-upload--text" slot="right">
          <!--<i class="el-icon-upload"></i>-->
          <button type="button" class="el-button el-button--default el-button--mini yc-button" @click="showUpload">
            <i class="el-icon-upload"></i>
            <span>导入</span>
          </button>
          <input ref="upload" type="file" name="file" class="el-upload__input" @change="getFile($event)" :accept="accept" >
        </div>
</template>

<script>
export default {
  name: 'yc-upload-file-single',
  props: {
    accept: {
      type: String,
      default: '.xlsx, .csv'
    },
    attach: {
      type: Object,
      default: function () {
        return {}
      }
    }
  },
  methods: {
    showUpload () {
      this.$refs.upload.click()
    },
    getFile (event) {
      var file = event.target.files[0]
      this.$emit('change', file, this.attach)
      event.target.value = null
    }
  }
}
</script>
